import requests  from "./request";
import mockRrequests from "./mockRequest";

//配置对象写法
export const reqCategoryList = ()=>requests({
    url:'/product/getBaseCategoryList',
    method:'GET'
  })
//简写
// 获取banner数据
export const reqGetBannerList = ()=>mockRrequests.get('/banner')

// 获取floor数据
export const reqFloorList = ()=>mockRrequests.get('/floor')

//获取搜索数据
export const reqGetSearchInfo = (params)=>requests({
  url:'/list',
  method:'POST',
  data:params
})

//获取商品详情信息 
export const reqGoodsInfo = (skuId)=>requests({
    url:`/item/${skuId}`,
    method:'GET'
})
//另一种写法
// export function reqGoodsInfo(skuId){
//   return requests({
//   url:`/item/${skuId}`,
//   method:'GET'
// })
// }

// 将产品添加到购物车

export const reqAddOrUpdateShopCart = (skuId,skuNum)=>requests({
  url: `/cart/addToCart/${skuId}/${skuNum}`,
  method: 'POST'
})

// 获取购物车列表数据
export const reqCartList = ()=>requests({
  url:'/cart/cartList',
  method:'GET'
})

// 删除购物车数据
export const reqDeleteCartById = (skuId)=>requests({
  url:`/cart/deleteCart/${skuId}`,
  method:'DELETE'
})

// 修改商品选中状态
export const reqUpdateCheckedById = (skuId,isChecked) => requests({
  url:`/cart/checkCart/${skuId}/${isChecked}`
})